unit ChaXun;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs,jpeg,IniFiles,Buttons, ExtCtrls,shellapi, pngimage;

type
  TfmianForm = class(TForm)
    Image0: TImage;
    procedure FormCreate(Sender: TObject);
    procedure Image0DblClick(Sender: TObject);
    procedure WMSysCommand(var Msg: TWMSysCommand); message WM_SYSCOMMAND;
  private
    { Private declarations }
    procedure ButtonClick(Sender: TObject);
  public
    MyButtons:array[0..100] of TImage;
    { Public declarations }
  end;

var
  fmianForm: TfmianForm;

implementation

{$R *.dfm}
uses QuitMima,Unit1;

procedure TfmianForm.ButtonClick(Sender: TObject);
var
  sLink,sButtonName: string;
  Myinifile:Tinifile;
begin
  Myinifile:= TIniFile.Create('.\config.ini');
  sButtonName:='Button'+inttostr(TSpeedButton(Sender).tag);
  sLink:=Myinifile.ReadString(sButtonName,'link','http://www.baidu.com');
  ShellExecute(Handle, 'open','Iexplore.exe',PWideChar(sLink),nil,SW_SHOWNORMAL);
end;

procedure TfmianForm.FormCreate(Sender: TObject);
var
  sPictureName:string;
  Myinifile:Tinifile;
  iButtonSum,i,iButtonChang,iButtonGao,iButtonX,iButtonY:Integer;
  sButtonNo,sButtonImage:string;
begin
    i:=0;
    Myinifile:= TIniFile.Create('.\config.ini');
    sPictureName:=Myinifile.ReadString('Background','Path','.\image\2.jpg');
    sPictureName:='.\images\'+sPictureName;
    iButtonSum:=Myinifile.ReadInteger('ButtonSum','Sum',3);
    iButtonChang:=Myinifile.ReadInteger('ButtonSum','ButtonChang',100);
    iButtonGao:=Myinifile.ReadInteger('ButtonSum','ButtonGao',50);
    Image0.Picture.LoadFromFile(sPictureName);
    while i <> iButtonSum do
    begin
      sButtonNo:='Button'+inttostr(i+1);
      iButtonX:=Myinifile.ReadInteger(sButtonNo,'x',100);
      iButtonY:=Myinifile.ReadInteger(sButtonNo,'y',100);
      sButtonImage:=Myinifile.ReadString(sButtonNo,'image','.\image\1.bmp');
      sButtonImage:='.\images\'+sButtonImage;
      MyButtons[i+1]:=TImage.Create(self);
      MyButtons[i+1].Parent:=Self;
      MyButtons[i+1].SetBounds(iButtonX,iButtonY,iButtonChang,iButtonGao);
      MyButtons[i+1].Tag:=i+1;
      MyButtons[i+1].Picture.LoadFromFile(sButtonImage);
  //    MyButtons[i+1].Glyph.LoadFromFile(sButtonImage);
      MyButtons[i+1].OnClick:=ButtonClick;
      inc(i);
    end;

end;

procedure TfmianForm.Image0DblClick(Sender: TObject);
var
  fmimaForm:TfmimaForm;
begin
  if GetKeyState(VK_CONTROL) < 0 then
  begin
    fmimaForm:=TfmimaForm.Create(nil);
    try
      fmimaForm.ShowModal;
    finally
      fmimaForm.Free;
    end;
  end;
end;

procedure TfmianForm.WMSysCommand(var Msg: TWMSysCommand);
begin
  if Msg.CmdType <> SC_CLOSE then
    inherited
end;

end.
